Skip to content

Redo Visualization#29

Merged
windisch merged 24 commits intomainfrom
redo_visuals
Mar 27, 2026
Merged

Redo Visualization#29
windisch merged 24 commits intomainfrom
redo_visuals

Conversation

@HSMarieK
Copy link
Copy Markdown
Collaborator

Complete overhaul of the visualization for better human interface.

@HSMarieK HSMarieK requested a review from windisch March 23, 2026 17:57
@windisch
Copy link
Copy Markdown
Contributor

windisch commented Mar 23, 2026

@HSMarieK: If I see correctly, line.setup_draw() is not needed any more, however, its still called from lineflow.simulation.environment.LineSimulation - do we have to adapt this?

@HSMarieK
Copy link
Copy Markdown
Collaborator Author

@windisch: That is the case, the line.setup_draw() Method does not have to be called there. I still have to take a closer look at lineflow.simulation.environment.LineSimulation to rule out any bugs.

@HSMarieK
Copy link
Copy Markdown
Collaborator Author

@windisch: Should I clean up the rest of the (now) redundant draw() Methods in the Objects?

Copy link
Copy Markdown
Contributor

@windisch windisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HSMarieK: This is just awesome work - thanks a lot for your contribution!

I refactored things a bit and gave the methods more speaking names. Moreover, I also reworked how the visualization-data is handled (formerly, a data list was send to methods and they appended, which I think is not required) - please have a careful look!

self._view.y += 10
class Visualization:

def __init__(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to have the initial center on the "average position"?

For instance, we could set it to None initially and than use the first data package to compute the average position of stationary objects?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could be done. Might be a really simple calculation. I will look into that.

except Empty:
break

def sort_connection_data(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data structure looks a bit wired at first glance. At the line object, we stack everything in a big list and then we have to sort it out. Do not have a suggestions right now how to make this smoother - thus fine for now!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone has a better idea, I am open for suggestions. This felt like the most obvious approach to me.

Copy link
Copy Markdown
Contributor

@windisch windisch Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of sending a list of dicts, we could send an object of a (yet to be implemented) class VisualizationData (or ConnectionData, but I like VisualizationData more, its what it is :-)) where everything can be accessed using attributes?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I went with dicts since I knew they could be serialized. I thought of using a dataclass instead, but I wanted it to work first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can refactor this later - should be no problem to serialize a own class if everything stays pure python.

@peerplexit
Copy link
Copy Markdown
Collaborator

peerplexit commented Mar 25, 2026

Hey @HSMarieK,
I also tried out the new visualisation. Really cool features, I like it!
I noticed a small bug. When the simulation starts, I think the first state visualized is the state T=1.
This leads to the minor bug, that if the step from T=0 -> T=1 takes long. The pygame window stays white.
Also if you press Shift+H in this "slow mode" the simulation is not closing immediately. It first finishes the tick and then closes. Idk if this is the expected behaviour.

You can reproduce it by yourself if you turn up the factor parameter of a line (for example 20 -> 20 seconds until you see the line).

@HSMarieK
Copy link
Copy Markdown
Collaborator Author

@peerplexit Thanks. I will look into the visualized simulation states. But the halting process by pressing Shift+H is working as intended. This seems slow, since the simulation is sleeping and thus not reacting to user input until it steps again.

@windisch windisch merged commit f8dc780 into main Mar 27, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants